<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>User Data in Kvaser Devices</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="kvaser.gif"/></td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('page_user_guide_userdata.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">User Data in Kvaser Devices </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#section_user_guide_userdata_trying">Trying out the concept</a></li>
<li class="level1"><a href="#section_example_c_customerdata_writing">Writing user data</a></li>
<li class="level1"><a href="#section_example_c_customerdata_obtaining">Obtaining your own password</a></li>
<li class="level1"><a href="#section_user_guide_userdata_reading">Reading User Data</a><ul><li class="level2"><a href="#section_example_c_read_customerdata">Program to read User Data</a></li>
</ul>
</li>
</ul>
</div>
<div class="textblock"><p>User Data is 8 bytes of data that can be permanently stored in a Kvaser Device. The User Data is associated with a user number and password, which both are administered by Kvaser and cannot be changed. The password is needed in order to write User Data, reading is not restricted so anyone can read the User Data.</p>
<dl class="section note"><dt>Note</dt><dd>The User Data is stored in a flash memory and the number of write cycles is limited. The ideal application is to write the data once, or a few times. A license key that your software validates would be a typical way of using this feature.</dd></dl>
<h1><a class="anchor" id="section_user_guide_userdata_trying"></a>
Trying out the concept</h1>
<p>The user number "100" and the corresponding password, "upHXy1" (without the quotes) is revealed and freely available in sample code. You are encouraged to try your implementation using this to verify that the User Data concept fits your application. If you decide to use this user number and password for "production use", please remember that the password is known to everyone. Contact <a href="#" onclick="location.href='mai'+'lto:'+'sal'+'es'+'@kv'+'as'+'er.'+'co'+'m'; return false;">sales<span style="display: none;">.nosp@m.</span>@kva<span style="display: none;">.nosp@m.</span>ser.c<span style="display: none;">.nosp@m.</span>om</a> for more information about how to obtain your own user number and password.</p>
<h1><a class="anchor" id="section_example_c_customerdata_writing"></a>
Writing user data</h1>
<p>To write user data, you use a command line program. Depending on your device, it is filo_setparam_userdata.exe for older devices or hydra_setparam_userdata.exe for newer devices. Please contact <a href="#" onclick="location.href='mai'+'lto:'+'sup'+'po'+'rt@'+'kv'+'ase'+'r.'+'com'; return false;">suppo<span style="display: none;">.nosp@m.</span>rt@k<span style="display: none;">.nosp@m.</span>vaser<span style="display: none;">.nosp@m.</span>.com</a> for more information.</p>
<h1><a class="anchor" id="section_example_c_customerdata_obtaining"></a>
Obtaining your own password</h1>
<p>Please contact <a href="#" onclick="location.href='mai'+'lto:'+'sal'+'es'+'@kv'+'as'+'er.'+'co'+'m'; return false;">sales<span style="display: none;">.nosp@m.</span>@kva<span style="display: none;">.nosp@m.</span>ser.c<span style="display: none;">.nosp@m.</span>om</a> for more information about how to obtain your own user number and password.</p>
<h1><a class="anchor" id="section_user_guide_userdata_reading"></a>
Reading User Data</h1>
<p>The User Data can be read using <a class="el" href="group__can__general.html#ga4a754a72cb9497994b6bc9133ee62282">kvReadDeviceCustomerData()</a>.</p>
<dl class="section note"><dt>Note</dt><dd>Anyone can read the user data. The writing is protected by a password but reading is not.</dd></dl>
<h2><a class="anchor" id="section_example_c_read_customerdata"></a>
Program to read User Data</h2>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">** This software is furnished as Redistributable under the Kvaser Software Licence</span></div><div class="line"><span class="comment">** https://www.kvaser.com/canlib-webhelp/page_license_and_copyright.html</span></div><div class="line"><span class="comment"></span></div><div class="line"><span class="comment">** Program to read User Data</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;windows.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="canlib_8h.html">canlib.h</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)</div><div class="line">{</div><div class="line">  <span class="keywordtype">int</span> i;</div><div class="line">  <a class="code" href="canlib_8h.html#ae3d1b041d62207d5336f93c089cd5b65">canHandle</a> hnd;</div><div class="line">  <a class="code" href="canstat_8h.html#a52b5e5c71832b0bd3c6a5b1fd48583e7">canStatus</a> stat;</div><div class="line">  <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> buf[8];</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (argc != 2) {</div><div class="line">    printf(<span class="stringliteral">&quot;Usage: read_customer_data channel\n&quot;</span>);</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  <a class="code" href="group__can__general.html#gaff1ec1d3416d3bdd56336a7b9ac008b1">canInitializeLibrary</a>();</div><div class="line">  hnd = <a class="code" href="group___c_a_n.html#gac377d182232fb4ec2fed881c2b9ab300">canOpenChannel</a>(atoi(argv[1]), 0);</div><div class="line">  <span class="keywordflow">if</span> (hnd &lt; 0) {</div><div class="line">    printf(<span class="stringliteral">&quot;Cannot open channel %s, error code %d\n&quot;</span>, argv[1], hnd);</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  stat = <a class="code" href="group__can__general.html#ga4a754a72cb9497994b6bc9133ee62282">kvReadDeviceCustomerData</a>(hnd,</div><div class="line">                                  100 <span class="comment">/*userNumber*/</span>,</div><div class="line">                                  0, <span class="comment">/* reserved, MBZ */</span></div><div class="line">                                  buf, <span class="keyword">sizeof</span>(buf));</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (stat != canOK) {</div><div class="line">    printf(<span class="stringliteral">&quot;kvReadDeviceCustomerData returned error code %d\n&quot;</span>, stat);</div><div class="line">    exit(1);</div><div class="line">  }</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;User data: &quot;</span>);</div><div class="line">  <span class="keywordflow">for</span> (i=0; i&lt;(signed)<span class="keyword">sizeof</span>(buf); i++) {</div><div class="line">    printf(<span class="stringliteral">&quot;%02x &quot;</span>, buf[i]);</div><div class="line">  }</div><div class="line">  printf(<span class="stringliteral">&quot;\n&quot;</span>);</div><div class="line"></div><div class="line">  <a class="code" href="group___c_a_n.html#ga49525373a4d08d93c651ec10f79dd36b">canClose</a>(hnd);</div><div class="line">  <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="page_canlib.html">CAN bus API (CANlib)</a></li>
    <li class="footer"> (canlib 5.38) Tue Feb 15 2022</li>
  </ul>
</div>
</body>
</html>
